package nl.maarten.docenthelp.entity;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

import nl.maarten.docenthelp.entity.thread.ListenThread;

public class Client 
{
	private static Session session;
	
	private String serverAddress;
	
	private int serverPort;
	private int udpServerPort;
	
	private ListenThread listenThread;
	
	public Client(String serverAddress, int serverPort, int udpServerPort)
	{
		this.serverAddress = serverAddress;
		this.serverPort = serverPort;
		this.udpServerPort = udpServerPort;
		
		init();
	}
	
	private void init()
	{		
		try
		{
			session = new Session("", new Socket(serverAddress, serverPort), udpServerPort);
			
			listenThread = new ListenThread();
			listenThread.start();
		} 
		catch (UnknownHostException e) 
		{
			e.printStackTrace();
		} 
		catch (IOException e) 
		{
			e.printStackTrace();
		}
	}
	
	public static Session getSession()
	{
		return session;
	}
	
}
